package com.woniu.liuzhougov.relatedinformation.controller.impl;

import com.woniu.liuzhougov.businessproject.vo.BusinessProjectUploadVO;
import com.woniu.liuzhougov.businessproject.vo.Result;
import com.woniu.liuzhougov.fileManage.constant.SysConstant;
import com.woniu.liuzhougov.relatedinformation.controller.AbstractRelatedInformationController;
import com.woniu.liuzhougov.relatedinformation.controller.RelatedInformationController;
import com.woniu.liuzhougov.relatedinformation.pojo.Commerce;
import com.woniu.liuzhougov.relatedinformation.pojo.RelatedInformation;
import com.woniu.liuzhougov.relatedinformation.service.RelatedInformationService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;

/**
 * @Description: desc
 * @author: Chris
 * @createDate: 2019/4/24 0024
 * @version: 1.0
 */
@Controller
@RequestMapping("commerce")
public class CommerceController extends AbstractRelatedInformationController<Commerce> implements RelatedInformationController<Commerce> {

    @Resource(name = "commerceService")
    private RelatedInformationService commerceService;


    @Override
    @RequestMapping("/list")
    @ResponseBody
    @RequiresPermissions(value = "commerce_listCommerces")
    public Result list() {
        return parentList(commerceService);
    }

    @Override
    @RequestMapping("/search")
    @ResponseBody
    @RequiresPermissions(value = "commerce_searchCommerce")
    public Result search(String name) {
        return parentSearch(commerceService,name);
    }

    @Override
    @RequestMapping("/delete")
    @ResponseBody
    @RequiresPermissions(value = "commerce_deleteCommerce   ")
    public Result delete(@RequestParam(value="deletelist[]")Integer[] deletelist) {
        return parentDelete(commerceService,deletelist);
    }

    @Override
    @RequestMapping("/add")
    @ResponseBody
    @RequiresPermissions(value = "commerce_addCommerce")
    public Result add(Commerce commerce) {
        return parentAdd(commerceService,commerce);
    }

    @Override
    @RequestMapping("/update")
    @ResponseBody
    @RequiresPermissions(value = "commerce_updateCommerce")
    public Result update(Commerce commerce) {
        return parentUpdate(commerceService,commerce);
    }

    @Override
    @RequestMapping("/initForm")
    @ResponseBody
    @RequiresPermissions(value = "commerce_updateCommerce")
    public Result initForm(Integer id) {
        return parentInitForm(commerceService,id);
    }

    @Override
    @RequestMapping("/upload")
    @ResponseBody
    @RequiresPermissions(value = "file_upload")
    public com.woniu.liuzhougov.common.utils.Result upload(MultipartFile file, HttpServletRequest request) throws IOException, IllegalStateException {
        return parentUpload(commerceService,file,request);
    }

    @Override
    @RequestMapping("/addFile")
    @ResponseBody
    @RequiresPermissions(value = "file_upload")
    public com.woniu.liuzhougov.common.utils.Result addFile(RelatedInformation fileData) {
        return parentAddFile(fileData);
    }
}
